package com.bio.dao.right.impl;

import java.util.List;

import org.hibernate.SQLQuery;
import org.hibernate.criterion.Restrictions;

import com.bio.dao.impl.HibernateDaoImpl;
import com.bio.dao.impl.HibernateQuery;
import com.bio.dao.right.TypemenuDao;
import com.bio.entity.right.Typemenu;

public class TypemenuDaoImpl extends HibernateDaoImpl<Typemenu> implements TypemenuDao{

	@Override
	public List<Typemenu> findAllByUsertype(Long userTypeId) {
		return new HibernateQuery<Typemenu>(this.getSessionFactory(), 
				this.getSession(), Typemenu.class).setPagination(null)
				                                  .addWhere(Restrictions.eq("userTypeId",userTypeId)).query().getResult();
	}

	@Override
	public void removeAllByUsertype(Long userTypeId) {
		String sql = "DELETE FROM table_right_type_menu WHERE user_type_id=" + userTypeId;
        SQLQuery sq = this.getSession().createSQLQuery(sql);
        sq.executeUpdate();
	}

	
}
